;; tinmop: an humble gemini and pleroma client
;; Copyright (C) 2020  cage

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(defpackage :idn
  (:use
   :cl
   :alexandria)
  (:export
   :host-unicode->ascii
   :host-ascii->unicode))

(defpackage :config
  (:use :cl)
  (:export
   :+sys-data-dir+
   :+sys-conf-dir+
   :+catalog-dir+
   :+text-domain+
   :+program-name+
   :+program-version+
   :+issue-tracker+
   :+openssl-bin+
   :+xdg-open-bin+
   :_
   :n_))

(defpackage :constants
  (:use :cl
        :alexandria
        :config)
  (:export
   :+help-about-message+
   :+http-code-ok+
   :+mime-type-jpg+
   :+mime-type-png+
   :+mime-type-html+
   :+db-file+
   :+fps+
   :+command-window-height+
   :+starting-init-file+
   :+box-height-diff+
   :+default-command-prompt+
   :+menu-button-ok+
   :+status-public-visibility+
   :+status-direct-visibility+
   :+folder-direct-message-prefix+
   :+folder-tag-prefix+
   :+mention-prefix+
   :+cache-tls-certificate-type+
   :+standard-editor+))

(defpackage :conditions
  (:use :cl
        :config)
  (:export
   :text-error
   :text
   :not-implemented-error
   :null-reference
   :out-of-bounds
   :length-error
   :different-length-error
   :command-not-found
   :column-not-found
   :with-default-on-error))

(defpackage :num-utils
  (:use :cl
        :constants)
  (:nicknames :num)
  (:export
   :safe-parse-number
   :parse-number-default
   :find-min-max
   :find-min
   :find-max
   :round-all
   :fract
   :sign
   :count-digit
   :fnv-hash-32
   :string-fnv-hash-32
   :fnv-hash-256
   :string-fnv-hash-256
   :*lcg-seed*
   :lcg-set-seed
   :lcg-next
   :lcg-next01
   :lcg-next-upto
   :lcg-next-in-range
   :lcg-next-in-range*
   :shellsort
   :multisort
   :multisort*
   :gen-multisort-test
   :*default-epsilon*
   :with-epsilon
   :add-epsilon-rel
   :epsilon=
   :epsilon<=
   :epsilon>=
   :binary-search))

(defpackage :misc-utils
  (:use :cl
        :constants)
  (:nicknames :misc)
  (:export
   :when-debug
   :debug-log
   :dbg
   :dbg-and-quit
   :dbg-stdout
   :code->char
   :char->code
   :swap
   :dump-hash-table
   :with-messages-start-end
   :safe-random
   :split-into-sublist
   :group-by
   :delete@
   :return-whole
   :safe-delete@
   :safe-all-but-last-elt
   :remove-compact-remap-sequence
   :remove-if-null
   :remove-if-not-null
   :intersperse
   :do-while
   :do-while*
   :not-null-p
   :permutation
   :shuffle
   :make-fresh-list
   :seq->list
   :lcat
   :vcat
   :fresh-list-insert@
   :fresh-list-subst@
   :make-array-frame
   :make-fresh-array
   :sequence->list
   :vector-empty-p
   :sequence-empty-p
   :safe-elt
   :safe-last-elt
   :safe-subseq
   :random-num-filled-vector
   :random-elt
   :safe-random-elt
   :copy-multiply
   :all-but-last-elt
   :list->array
   :list->simple-array
   :copy-list-into-array
   :array-slice
   :2byte->word
   :2word->int
   :byte->int
   :bytes->string
   :read-ieee-float-32
   :int16->bytes
   :int32->bytes
   :define-offset-size
   :define-parse-header-chunk
   :read-list
   :read-array
   :read-all
   :read-line-into-array
   :definline
   :+cache-invalid-value+
   :defcached
   :defcached-list
   :function-name
   :fn-delay
   :unsplice
   :defalias
   :defun-inline-function
   :format-fn-symbol
   :check-body-keywords
   :format-keyword
   :a->function
   :gen-type-p
   :define-compiler-macros
   :defmethod-inline-function
   :nest-expressions
   :replace-e!
   :+nil-equiv-bag+
   :build-plist
   :build-assocs-chain
   :recursive-assoc
   :recursive-assoc-just-before
   :n-setf-path-value
   :plist-path-value
   :gen-trivial-plist-predicates
   :gen-trivial-plist-predicate
   :gen-trivial-plist-get
   :gen-trivial-plist-gets
   :gen-vec-comp
   :make-null-pointer
   :with-load-forms-in-var
   :time-unix->universal
   :time-second-of
   :time-minutes-of
   :time-hour-of
   :time-date-of
   :time-month-of
   :time-year-of
   :time-day-of
   :time-daylight-p-of
   :time-zone-of
   :year->timestamp
   :current-year
   :extract-year-from-timestamp
   :format-time
   :binary-search
   :defun-w-lock
   :with-lock
   :get-url-content
   :with-profile-time
   :with-debug-print-profile-time))

(defpackage :box
  (:use
   :cl)
  (:export
   :box
   :boxp
   :unbox
   :dbox
   :dboxp
   :dunbox))

(defpackage :filesystem-utils
  (:use
   :cl
   :alexandria)
  (:nicknames :fs)
  (:export
   :+file-path-regex+
   :+s-irwxu+
   :+s-irusr+
   :+s-iwusr+
   :+s-ixusr+
   :+s-irwxg+
   :+s-irgrp+
   :+s-iwgrp+
   :+s-ixgrp+
   :+s-irwxo+
   :+s-iroth+
   :+s-iwoth+
   :+s-ixoth+
   :+s-isuid+
   :+s-isgid+
   :*directory-sep-regexp*
   :*directory-sep*
   :copy-a-file
   :file-size
   :slurp-file
   :dump-sequence-to-file
   :create-file
   :cat-parent-dir
   :has-extension
   :get-extension
   :strip-extension
   :add-extension
   :do-directory
   :collect-children
   :prepend-pwd
   :search-matching-file
   :regular-file-p
   :dirp
   :split-path-elements
   :path-last-element
   :path-first-element
   :path-to-hidden-file-p
   :parent-dir-path
   :strip-dirs-from-path
   :get-stat-mtime
   :get-stat-ctime
   :get-stat-atime
   :file-outdated-p
   :file-exists-p
   :directory-exists-p
   :file-length-if-exists
   :delete-file-if-exists
   :file-hash
   :home-dir
   :*temporary-files-created*
   :temporary-file
   :clean-temporary-files
   :with-anaphoric-temp-file
   :temp-file
   :file-can-write-p
   :set-file-permissions
   :cached-directory-files
   :directory-files
   :make-directory
   :package-path
   :file-in-package
   :link-file-path
   :file-is-link-if-else
   :pathname->namestring
   :namestring->pathname
   :read-single-form
   :eq-filename))

(defpackage :os-utils
  (:use
   :cl
   :config
   :constants)
  (:export
   :+ssl-cert-name+
   :+ssl-key-name+
   :cpu-number
   :xdg-open
   :getenv
   :default-temp-dir
   :pwd
   :open-with-editor
   :exit-program
   :user-cache-dir
   :cached-file-path
   :generate-ssl-certificate
   :send-to-pipe
   :open-link-with-program
   :open-resource-with-external-program))

(defpackage :text-utils
  (:use
   :cl
   :config)
  (:import-from :misc :definline)
  (:export
   :+float-regexp+
   :+integer-regexp+
   :*blanks*
   :uchar-length
   :utf8-encoded-p
   :clean-unprintable-chars
   :to-s
   :strcat
   :strcat*
   :join-with-strings
   :join-with-strings*
   :split-words
   :split-lines
   :strip-prefix
   :strip-withespaces
   :common-prefix
   :basename
   :wrap-with
   :build-string
   :right-padding
   :right-padding-suffix
   :left-padding
   :left-padding-prefix
   :ellipsize
   :justify-monospaced-text
   :flush-left-mono-text
   :string-empty-p
   :string-not-empty-p
   :string-starts-with-p
   :string-ends-with-p
   :trim-blanks
   :find-max-line-length
   :box-fit-single-column
   :box-fit-multiple-column
   :annotated-text-symbol
   :annotated-text-value
   :box-fit-multiple-column-annotated
   :collect-links
   :percent-encode
   :percent-decode
   :percent-encoded-p
   :maybe-percent-encode
   :display-corrupting-utf8-p
   :remove-corrupting-utf8-chars))

(defpackage :html-utils
  (:use
   :cl
   :alexandria
   :config
   :text-utils)
  (:export
   :make-tag-node
   :tag
   :attributes
   :attribute-key
   :attribute-value
   :children
   :tag=
   :find-attribute
   :find-tag
   :position-tag
   :node->link
   :html->text))

(defpackage :resources-utils
  (:use :cl
        :cl-ppcre
        :config
        :constants
        :filesystem-utils
        :text-utils)
  (:nicknames :res)
  (:export
   :init
   :home-datadir
   :home-confdir
   :return-home-filename
   :return-system-filename
   :create-empty-in-home
   :get-config-file
   :get-sys-config-file
   :get-data-file))

(defpackage :crypto-utils
  (:use :cl
        :alexandria
        :cl-ppcre
        :config
        :constants)
  (:export
   :crypto-text-p
   :generate-key
   :encrypt-message
   :decrypt-message))

(defpackage :interfaces
  (:use :cl
        :alexandria
        :constants
        :misc)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :clone
   :clone-into
   :copy-flat
   :copy-flat-into
   :with-simple-clone
   :with-simple-copy-flat
   :serialize
   :serialize-to-stream
   :deserialize
   :post-deserialization-fix))

(defpackage :mtree-utils
  (:use
   :cl
   :interfaces
   :text-utils)
  (:nicknames :mtree)
  (:export
   :random-choose-leaf
   :traverse-apply-tree
   :traverse-napply-tree
   :traverse-find-if-tree
   :traverse-find-all-if-tree
   :traverse-apply-tree-cdr
   :traverse-nadd-child
   :traverse-ndelete-child
   :nappend-child
   :navigate
   :m-tree
   :*use-pprint-tree*
   :pprint-tree
   :children
   :parent
   :data
   :add-child
   :add-children
   :add-children*
   :child-data-pushnew
   :graft-branch
   :make-node
   :find-node
   :leafp
   :rootp
   :top-down-visit
   :bottom-up-visit
   :remove-all-children
   :remove-child
   :remove-child-if
   :do-children
   :do-children-from-end
   :find-child
   :find-child-if
   :count-leaves
   :count-nodes
   :collect-nodes-data
   :mtree-equal
   :root-node
   :sorted-m-tree
   :tree->text-lines
   :tree->annotated-lines))

(defpackage :bs-tree
  (:use
   :cl
   :interfaces)
  (:shadow :search :map)
  (:export
   :node
   :parent
   :data
   :left
   :right
   :make-node
   :make-leaf
   :make-root-node
   :%key
   :+data+
   :+left+
   :+right+
   :+parent+
   :node->string
   :search
   :search-opt
   :with-insert-local-function
   :insert
   :leafp
   :all-children-leaf-p
   :map
   :map-node
   :walk
   :bstp
   :node->dot
   :reconstruct-parent
   :find-max-node
   :to-sexp
   :from-sexp))

(defpackage :rb-tree
  (:use
   :cl
   :interfaces
   :bs-tree)
  (:shadowing-import-from :bs-tree :search :map)
  (:export
   :+rb-red+
   :+rb-black+
   :+rb-color+
   :rb-node
   :color
   :make-rb-node
   :make-rb-leaf
   :make-root-rb-node
   :data
   :left
   :right
   :node->string
   :search
   :search-opt
   :with-insert-local-function
   :insert
   :remove-node
   :leafp
   :map
   :map-node
   :balancedp
   :walk
   :bstp
   :node->dot
   :reconstruct-parent
   :to-sexp
   :from-sexp))

(defpackage :priority-queue
  (:use :cl)
  (:nicknames :pq)
  (:export
   :priority-queue
   :key-function
   :compare-function
   :equal-function
   :push-element
   :pop-element
   :find-element
   :remove-element
   :map-elements
   :count-elements-if
   :remove-element-if
   :map-events
   :emptyp
   :with-min-queue))

(defpackage :queue
  (:use :cl)
  (:nicknames :qu)
  (:shadow :push :pop :find)
  (:export
   :*equal-function*
   :*key-function*
   :push
   :pop
   :find
   :emptyp
   :with-queue
   :simple-queue
   :container
   :q-pop
   :q-peek
   :q-push
   :q-empty-p
   :q-size
   :q-sort
   :q-dbg-print))

(defpackage :stack
  (:use
   :cl
   :alexandria)
  (:export
   :stack
   :stack-push
   :stack-pop
   :stack-find
   :stack-empty-p
   :stack-remove-element
   :stack-select
   :stack-position
   :stack-raise-to-top
   :stack-empty-p
   :do-stack-element))

(defpackage :uri-parser
  (:use
   :cl
   :alexandria
   :esrap
   :cl-ppcre
   :text-utils)
  (:nicknames :uri)
  (:export
   :uri
   :copy-uri
   :render-uri
   :uri-parse
   :scheme
   :user-info
   :host
   :port
   :path
   :query
   :fragment
   :normalize-path
   :make-uri))

(defpackage :iri-parser
  (:use
   :cl
   :alexandria
   :esrap
   :cl-ppcre
   :text-utils)
  (:nicknames :iri)
  (:export
   :+segment-separator+
   :iri
   :copy-iri
   :render-iri
   :make-iri
   :iri-parse
   :absolute-url-p
   :ipv4-address-p
   :ipv6-address-p))

(defpackage :tour-mode-parser
  (:use
   :cl
   :alexandria
   :esrap
   :cl-ppcre
   :text-utils)
  (:export
   :range-from
   :range-to
   :range-p
   :parse-tour-mode))

(defpackage :x509
  (:use
   :cl
   :alexandria)
  (:export
   :dump-certificate))

(defpackage :db-utils
    (:use
     :cl
     :alexandria
     :cl-ppcre
     :sxql
     :local-time
     :config
     :constants
     :text-utils)
    (:export
     :+characters-trouble-name+
     :*connection*
     :fetch
     :fetch-all
     :close-db
     :connectedp
     :with-db-transaction
     :db-path
     :quote-symbol
     :init-connection
     :with-ready-database
     :with-disabled-foreign
     :do-rows
     :prepare-for-sql-like
     :object-exists-in-db-p
     :object-count-in-db
     :query-low-level
     :db-nil-p
     :db-not-nil-p
     :db-getf
     :db-nil->lisp
     :if-db-nil-else
     :count-all
     :query
     :query->sql
     :local-time-obj-now
     :decode-date-string
     :decode-datetime-string
     :encode-datetime-string
     :encoded-datetime-year
     :make-insert
     :make-delete
     :make-update
     :get-max-id
     :get-min-id
     :decode-blob
     :rows->tsv
     :table-exists-p
     :prepare-for-db
     :last-inserted-rowid))

(defpackage :db
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :sxql
   :sxql-composer
   :config
   :constants
   :db-utils
   :text-utils)
  (:export
   :+db-true+
   :+db-false+
   :+other-id+
   :+table-account+
   :+table-status+
   :+table-attachment+
   :+table-saved-status+
   :+table-crypto-data+
   :+table-gemini-subscription+
   :+federated-timeline+
   :+local-timeline+
   :+home-timeline+
   :+direct-timeline+
   :+default-status-folder+
   :+mentions-status-folder+
   :+default-tag-timeline+
   :+default-converation-timeline+
   :+message-index-start+
   :+tag-separator+
   :+make-close+
   :prepare-table
   :hidden-recipient-p
   :default-timelines
   :message-index->sequence-index
   :timeline-type->description
   :maybe-build-all-tables
   :build-all-indices
   :delete-all-tables
   :delete-all-views
   :delete-database
   :fetch-all-rows
   :table->alist
   :fetch-from-id
   :fetch-single
   :delete-by-id
   :account-ignored-p
   :user-ignored-p
   :acct->user
   :acct->id
   :username->id
   :user-exists-p
   :user-id->user
   :user-id->username
   :insert-in-history
   :previous-in-history
   :next-in-history
   :most-recent-history-id
   :purge-history
   :history-prompt->values
   :all-poll-options
   :find-poll
   :find-poll-option
   :find-poll-bound-to-status
   :chat-message-exists-p
   :find-chat
   :mark-all-chat-messages-read
   :count-unread-chat-messages
   :chat-change-label
   :chat-exists-p
   :all-chats
   :all-chat-messages
   :all-chat-links
   :last-chat-message-id
   :update-db
   :message-root
   :message-children
   :message-root->tree
   :message->thread-users
   :message-id->tree
   :message-from-timeline-folder-message-index
   :message-index->tree
   :single-status-exists-p
   :find-status-id
   :find-message-id
   :data-id
   :row-id
   :row-type
   :row-label
   :row-message-visibility
   :row-message-status-id
   :row-message-index
   :row-message-timeline
   :row-message-folder
   :row-message-username
   :row-message-user-display-name
   :row-message-content
   :row-message-rendered-text
   :row-message-creation-time
   :row-message-subject
   :row-message-tags
   :row-message-reblog-id
   :row-lockedp
   :row-user-username
   :row-tag-got-new-message
   :row-conversation-folder
   :row-conversation-root-status-id
   :row-conversation-ignored-p
   :row-poll-expired-p
   :row-poll-multiple-vote-p
   :row-title
   :row-subtitle
   :row-url
   :row-expire-date
   :row-account-id
   :row-updated-at
   :row-created-at
   :row-chat-id
   :row-votes-count
   :row-message-reply-to-id
   :row-text-url
   :row-cache-key
   :row-cache-type
   :row-cache-accessed-at
   :row-cache-created-at
   :row-seenp
   :next-status-tree
   :previous-status-tree
   :message-tree-root-equal
   :annotated-tree-line->data-plist
   :renumber-timeline-message-index
   :renumber-all-timelines
   :all-attachments-to-status
   :attachment-to-chat-message
   :all-attachments-urls-to-status
   :mark-status-red-p
   :mark-status-unread
   :mark-status-deleted-p
   :mark-status-prevent-deletion
   :count-status-redp
   :count-status
   :search-message-text-body
   :search-next-message-body
   :search-previous-message-body
   :search-next-message-meta
   :search-previous-message-meta
   :search-next-unread-message
   :last-message-index-status
   :last-status-id-timeline-folder
   :first-status-id-timeline-folder
   :last-ignored-status-id-timeline-folder
   :first-ignored-status-id-timeline-folder
   :last-pagination-status-id-timeline-folder
   :first-pagination-status-id-timeline-folder
   :find-pagination-status
   :add-to-pagination-status
   :remove-pagination-status
   :count-status-marked-to-delete
   :delete-all-statuses-marked-deleted
   :tags-histogram-foreground
   :max-username-length
   :keyword->dbcolumn
   :folder-exists-p
   :conversation-root-captured-p
   :timeline-exists-p
   :move-message-to-folder
   :move-tree-to-folder
   :last-status-id-in-tree
   :all-timelines-in-folder
   :all-folders
   :all-timelines
   :ignore-status-author
   :unignore-status-author
   :unignore-author
   :all-usernames
   :all-followed-usernames
   :all-unfollowed-usernames
   :all-ignored-usernames
   :status-ignored-p
   :status-skipped-p
   :add-to-status-ignored
   :add-to-status-skipped
   :add-to-followers
   :remove-from-followers
   :forget-all-statuses-marked-deleted
   :status-id->username
   :subscribe-to-tag
   :unsubscribe-to-tag
   :tag->folder-name
   :folder-name->tag
   :all-tag-paginations-status
   :all-subscribed-tags
   :all-subscribed-tags-name
   :tag-folder-name-p
   :more-recent-tag-fetched-p
   :all-tags-with-new-message-fetched
   :update-last-seen-status-subscribed-tag
   :tag-histogram
   :mark-tag-got-new-messages
   :unmark-tag-got-new-messages
   :max-id-conversations
   :all-conversations
   :all-conversations-id
   :add-conversation
   :conversation-id->folder
   :all-conversation-folders
   :update-conversation-folder
   :update-conversation-folder-by-id
   :update-conversation-by-id
   :conversation-folder-exists-p
   :change-conversation-name
   :conversation-stats
   :conversation-id
   :messages-red
   :messages-to-read
   :conversation-name
   :conversation-read/red
   :all-conversation-stats
   :ignore-conversation
   :delete-conversation
   :import-crypto-data
   :crypto-user-key
   :cache-invalidate
   :cache-put
   :cache-get
   :cache-get-value
   :cache-expired-p
   :tofu-passes-p
   :tofu-delete
   :ssl-cert-find
   :find-tls-certificates-rows
   :gemini-subscribe-url
   :gemini-find-subscription
   :gemini-all-subscriptions
   :row-seen-count
   :row-unseen-count
   :find-gemlog-entry
   :gemini-cancel-subscription
   :add-gemlog-entries
   :gemlog-mark-as-seen
   :gemlog-url
   :gemlog-title
   :gemlog-subtitle
   :row-post-date
   :row-post-title
   :row-post-link
   :row-post-seenp
   :gemlog-entries
   :delete-gemlog-entry
   :purge-seen-gemlog-entries))

(defpackage :date-formatter
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :esrap
   :config
   :constants
   :misc
   :text-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :expand-date-formatter-spec))

(defpackage :emoji-shortcodes
  (:use :cl)
  (:export
   :shortcode-lookup
   :emojify))

(defpackage :software-configuration
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :esrap
   :config
   :constants
   :text-utils
   :misc
   :mtree)
  (:nicknames :swconf)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :+conf-filename+
   :+shared-conf-filename+
   :+key-background+
   :+key-foreground+
   :+key-width+
   :+key-root+
   :+key-height+
   :+key-value+
   :+key-new-message-mark+
   :+key-window+
   :+key-focus+
   :+key-mark+
   :+key-vote-vertical-bar+
   :+key-info-dialog+
   :+key-help-dialog+
   :+key-error-dialog+
   :+key-input-dialog+
   :+key-notify-window+
   :+key-notification-life+
   :+key-modeline+
   :+key-date-format+
   :+key-main-window+
   :+key-thread-window+
   :+key-message-window+
   :+key-chat-window+
   :+key-chats-list-window+
   :+key-gemini-subscription-window+
   :+key-gemini-toc-window+
   :+key-favourite+
   :+key-sensitive+
   :+key-boosted+
   :+key-tags-window+
   :+key-open-attach-window+
   :+key-open-message-link-window+
   :+key-open-gemini-stream-window+
   :+key-gemini-certificates-window+
   :+key-conversations-window+
   :+key-keybindings-window+
   :+key-suggestions-window+
   :+key-command-window+
   :+key-editor+
   :+key-username+
   :+key-server+
   :+key-message+
   :+key-selected+
   :+key-deleted+
   :+key-read+
   :+key-unread+
   :+key-color-re+
   :+key-tree+
   :+key-branch+
   :+key-arrow+
   :+key-data+
   :+key-data-leaf+
   :+key-purge-history-days-offset+
   :*allowed-status-visibility*
   :*allowed-attachment-type*
   :*software-configuration*
   :color-re-assign
   :re
   :color-name
   :color-value
   :attributes
   :parse
   :perform-missing-value-check
   :load-config-file
   :external-editor
   :gemini-default-favicon
   :directory-symbol
   :gemini-fetch-favicon-p
   :gemini-link-prefix-to-gemini
   :gemini-link-prefix-to-other
   :gemini-quote-prefix
   :gemini-quote-prefix
   :gemini-h1-prefix
   :gemini-h2-prefix
   :gemini-h3-prefix
   :gemini-bullet-prefix
   :gemini-preformatted-fg
   :gemini-certificates-window-colors
   :gemini-toc-padding-char
   :signature-file-path
   :vote-vertical-bar
   :crypted-mark-value
   :quick-help-header-colors
   :window-titles-ends
   :tags-histogram-foreground
   :tags-new-message-mark
   :conversation-window-read-colors
   :conversation-window-unread-colors
   :max-message-length
   :max-report-comment-length
   :quote-char
   :max-attachments-allowed
   :color-regexps
   :ignore-users-regexps
   :win-bg
   :win-fg
   :win-height
   :win-width
   :command-separator-config-values
   :command-error-message-colors
   :command-info-message-colors
   :tree-config-colors
   :tree-config-rendering-values
   :make-tree-colormap
   :config-purge-history-days-offset
   :config-purge-cage-days-offset
   :config-notification-life
   :config-notify-window-geometry
   :config-notification-icon
   :config-server-name
   :config-username
   :config-password-echo-character
   :config-win-focus-mark
   :link-regex->program-to-use
   :use-tinmop-as-external-program-p
   :thread-message-symbol
   :thread-message-read-colors
   :thread-message-unread-colors
   :thread-message-selected-colors
   :thread-message-deleted-colors
   :modeline-colors
   :modeline-fmt
   :date-fmt
   :message-window-locked-account-mark
   :message-window-unlocked-account-mark
   :message-window-account-locking-status-mark
   :message-window-line-mark-values
   :message-windows-visibility-marks
   :message-window-attachments-header
   :form-style
   :background
   :foreground
   :input-background
   :input-foreground
   :selected-background
   :selected-foreground))

(defpackage :tui-utils
    (:use
     :cl
     :alexandria
     :cl-ppcre
     :local-time
     :croatoan
     :config
     :constants
     :interfaces
     :text-utils)
    (:nicknames :tui)
    (:import-from :misc-utils :defalias)
    (:export
     :make-win-background
     :make-croatoan-window
     :make-blocking-croatoan-window
     :make-screen
     :make-tui-char
     :make-tui-string
     :tui-format
     :decode-key-event
     :colorize-tree-element
     :colorize-tree-line
     :text-length
     :find-max-line-width
     :ncat-complex-string
     :to-tui-string
     :cat-complex-string
     :cat-tui-string
     :tui-char->char
     :tui-string->chars-string
     :tui-string-subseq
     :text-ellipsis
     :right-pad-text
     :text->tui-attribute
     :assemble-attributes
     :attribute-reverse
     :attribute-bold
     :attribute-underline
     :attribute-italic
     :attribute-blink
     :attribute-dim
     :attribute-invisible
     :combine-attributes
     :colorize-line
     :colorized-line->tui-string
     :apply-coloring
     :standard-error-notify-life
     :with-notify-errors
     :with-print-error-message
     :make-tui-char
     :make-tui-string))

(defpackage :command-line
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :config
   :constants
   :text-utils
   :misc-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :*start-folder*
   :*start-timeline*
   :*update-timeline*
   :*script-file*
   :*module-file*
   :*check-follow-requests*
   :*reset-timeline-pagination*
   :*notify-mentions*
   :*gemini-url*
   :*update-timeline-climb-message-tree*
   :manage-opts))

(defpackage :specials
  (:use
   :cl
   :config
   :constants)
  (:export
   :*main-window*
   :*keybindings-suggestions-window*
   :*strings-suggestions-window*
   :*command-window*
   :*thread-window*
   :*message-window*
   :*send-message-window*
   :*follow-requests-window*
   :*tags-window*
   :*conversations-window*
   :*open-attach-window*
   :*open-message-link-window*
   :*gemini-streams-window*
   :*gemini-certificates-window*
   :*gemini-subscription-window*
   :*gemini-toc-window*
   :*chats-list-window*))

(defpackage :complete
  (:use
   :cl
   :alexandria
   :osicat)
  (:export
   :*complete-function*
   :shortest-candidate
   :directory-complete
   :tilde-expand-string
   :folder-complete
   :timeline-complete-fn
   :ignored-username-complete
   :initialize-complete-username-cache
   :username-complete
   :visibility-complete
   :unfollowed-user-complete
   :followed-user-complete
   :tags-complete
   :conversation-folder
   :make-complete-gemini-iri-fn
   :complete-chat-message
   :complete-always-empty))

(defpackage :program-events
  (:use
   :cl
   :alexandria
   :priority-queue
   :config
   :constants
   :priority-queue
   :misc
   :box)
  (:shadowing-import-from :misc           :random-elt :shuffle)
  (:shadowing-import-from :priority-queue :emptyp)
  (:export
   :+standard-event-priority+
   :+minimum-event-priority+
   :+maximum-event-priority+
   :*process-events-immediately*
   :with-stop-event-dispatching
   :stop-event-dispatching-p
   :program-event
   :event-id
   :payload
   :condition-variable
   :priority
   :reinitialize-id
   :events-queue
   :lock
   :push-event
   :event-available-p
   :pop-event
   :remove-event
   :remove-event-if
   :find-event
   :ask-user-input-string-event
   :user-input-string-event
   :notify-user-event
   :remove-notify-user-event
   :save-timeline-in-db-event
   :timeline-type
   :localp
   :min-id
   :fetch-remote-status-event
   :process-event
   :search-next-event
   :search-regex-message-content-event
   :thread-search-message-body-event
   :search-direction
   :thread-search-message-meta-event
   :thread-goto-message
   :delete-all-status-event
   :quit-program-event
   :error-message-event
   :info-message-event
   :error-dialog-event
   :info-dialog-event
   :move-selected-tree-event
   :refresh-thread-windows-event
   :favourite-status-event
   :unfavourite-status-event
   :reblog-status-event
   :unreblog-status-event
   :unignore-user-event
   :send-message-change-subject-event
   :send-message-change-mentions-event
   :send-message-change-visibility-event
   :open-send-message-window-event
   :send-message-add-attachment-event
   :send-message-event
   :use-ui-notification
   :follow-user-event
   :unfollow-user-event
   :open-follow-requests-window-event
   :subscribe-tags-event
   :unsubscribe-tags-event
   :update-last-refresh-subscribe-tags-event
   :notify-fetched-new-tag-messages-event
   :tag-mark-got-messages-event
   :refresh-tag-window-event
   :update-conversations-event
   :change-conversation-name-event
   :old-name
   :new-name
   :refresh-conversations-window-event
   :ignore-conversations-event
   :delete-conversations-event
   :update-mentions-event
   :expand-thread-event
   :report-status-event
   :add-crypto-data-event
   :poll-vote-event
   :gemini-request-event
   :gemini-back-event
   :gemini-got-line-event
   :gemini-abort-all-downloading-event
   :gemini-push-behind-downloading-event
   :gemini-abort-downloading-event
   :gemini-compact-lines-event
   :gemini-enqueue-download-event
   :gemini-gemlog-subscribe-event
   :gemlog-cancel-subscription-event
   :gemlog-show-event
   :gemlog-refresh-all-event
   :gemini-toc-jump-to-section
   :gemini-toc-open
   :get-chat-messages-event
   :get-chats-event
   :chat-show-event
   :update-all-chat-messages-event
   :chat-post-message-event
   :chat-change-label-event
   :chat-create-event
   :search-link-event
   :help-apropos-event
   :redraw-window-event
   :function-event
   :send-to-pipe-event
   :dispatch-program-events
   :add-pagination-status-event
   :status-id
   :timeline))

(defpackage :api-pleroma
  (:use
   :cl
   :alexandria
   :config
   :constants
   :misc)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :chat-message
   :message-id
   :nreadp
   :emojis
   :updated-at
   :created-at
   :content
   :chat-id
   :attachment
   :account-id
   :chat
   :unread-count
   :last-message
   :account
   :create-chat
   :get-all-chats
   :post-chat-message
   :fetch-chat-messages
   :delete-chat-message
   :get-chat-messages
   :get-chats
   :post-on-chat
   :create-new-chat))

(defpackage :api-client
  (:use
   :cl
   :alexandria
   :config
   :constants
   :db-utils
   :interfaces
   :text-utils
   :misc)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:nicknames :client)
  (:export
   :*client*
   :*client-lock*
   :forget-credentials
   :authorize
   :defun-api-call
   :favourite-status
   :unfavourite-status
   :reblog-status
   :unreblog-status
   :get-timeline
   :update-timeline
   :tag->folder-name
   :tag-name
   :update-subscribed-tags
   :fetch-remote-status
   :get-remote-status
   :send-status
   :get-status-context
   :search-user
   :follow-user
   :unfollow-user
   :follow-requests
   :accept-follow-request
   :reject-follow-request
   :conversation-tree
   :id
   :last-status
   :status-tree
   :root
   :conversation-root-id
   :conversations
   :expand-conversations-tree
   :make-report
   :delete-conversation
   :get-activity
   :application-credentials
   :bookmarks
   :bookmark
   :unbookmark
   :polls
   :poll-vote
   :get-notifications
   :delete-notification
   :sort-id<
   :id=
   :all-mentions
   :update-mentions-folder
   :expand-status-thread
   :make-placeholder-tag-histogram
   :init))

(defpackage :hooks
  (:use
   :cl
   :alexandria)
  (:export
   :*hook*
   :add-hook
   :remove-hook
   :run-hooks
   :run-hook
   :run-hook-compose
   :run-hook-until-failure
   :run-hook-until-success
   :*before-main-loop*
   :*before-quit*
   :*before-rendering-message-text*
   :*before-sending-message*
   :*skip-message-hook*
   :*after-saving-message*
   :*before-displaying-links-hook*))

(defpackage :keybindings
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :esrap
   :config
   :constants
   :text-utils
   :misc
   :mtree)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :*global-keymap*
   :*thread-keymap*
   :*tags-keymap*
   :*conversations-keymap*
   :*message-keymap*
   :*gemini-message-keymap*
   :*send-message-keymap*
   :*follow-requests-keymap*
   :*open-attach-keymap*
   :*open-message-link-keymap*
   :*open-gemini-link-keymap*
   :*gemini-downloads-keymap*
   :*gemini-certificates-keymap*
   :*chats-list-keymap*
   :*chat-message-keymap*
   :*gemlog-subscription-keymap*
   :*gemini-toc-keymap*
   :define-key
   :init-keyboard-mapping
   :find-keymap-node
   :humanize-key
   :help-fields-get-function
   :help-fields-get-text
   :print-help))

(defpackage :windows
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :stack
   :text-utils
   :misc
   :mtree
   :specials
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:shadowing-import-from :stack :stack :stack-push :stack-pop :stack-empty-p)
  (:export
   :key-config-holder
   :key-config
   :tree-holder
   :tree-color-map
   :render-arrow-value
   :render-leaf-value
   :render-branch-value
   :render-spacer-value
   :render-vertical-line-value
   :refresh-config-color-map
   :wrapper-window
   :croatoan-window
   :with-croatoan-window
   :when-window-shown
   :keybindings
   :win-clear
   :win-width
   :win-height
   :win-x
   :win-y
   :win-box
   :win-bgcolor
   :win-fgcolor
   :win-refresh
   :win-close
   :win-raise-to-top
   :win-move-cursor
   :win-move-cursor-direction
   :win-move
   :win-resize
   :win-show
   :win-hide
   :win-shown-p
   :menu-select
   :win-width-no-border
   :win-height-no-border
   :with-window-width
   :with-window-height
   :with-window-sizes
   :calc-center-on-window-width
   :calc-bottom-of-window-height
   :print-text
   :refresh-config
   :refresh-config-colors
   :refresh-config-sizes
   :calculate
   :draw
   :draw-all
   :refresh-config-all
   :calculate-all
   :cursor-show
   :cursor-hide
   :add-flush-left-text
   :make-blocking-message-dialog
   :make-error-message-dialog
   :make-info-message-dialog
   :make-checklist-dialog
   :make-input-dialog
   :focus-marked-window
   :in-focus
   :in-focus-p
   :border-window
   :uses-border-p
   :title-window))

(defpackage :notify-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :notify-window
   :pending
   :notify-window-p
   :draw-pending
   :make-notification-window))

(defpackage :suggestions-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :specials
   :windows
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :suggestions-window
   :paginated-info
   :current-page
   :update-suggestions
   :draw-pagination-info))

(defpackage :complete-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :tui-utils
   :specials
   :windows
   :suggestions-window)

  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :complete-window
   :init))

(defpackage :keybindings-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :suggestions-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :keybindings-window
   :keybindings-tree
   :update-keybindings-tree
   :init))

(defpackage :point-tracker
  (:use
   :cl
   :alexandria
   :config
   :constants
   :misc
   :text-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :point-tracker
   :point-position
   :point-fg
   :point-bg
   :prompt
   :no-prompt-point-pos
   :move-point-left
   :move-point-right
   :move-point
   :move-point-to-end
   :move-point-to-start
   :insert-at-point
   :delete-at-point))

(defpackage :modeline-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :esrap
   :config
   :constants
   :misc
   :text-utils
   :windows
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :modeline-window
   :mapping-code->fn
   :modeline-src
   :modeline-text
   :modeline-fg
   :modeline-bg
   :expand-modeline-spec
   :refresh-modeline-config
   :add-modeline-char-expander))

(defpackage :line-oriented-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :modeline-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:import-from :keybindings-window :update-keybindings-tree)
  (:export
   :line
   :selected-fg
   :selected-bg
   :normal-fg
   :normal-bg
   :normal-text
   :selected-text
   :deleted-text
   :fields
   :index
   :selected
   :selectedp
   :row-oriented-widget
   :single-row-height
   :top-row-padding
   :rows
   :row-selected-index
   :y-current-row
   :top-rows-slice
   :bottom-rows-slice
   :renderizable-rows-data
   :unselect-all
   :select-row
   :select-first-row
   :adjust-rows-select-first
   :adjust-selected-rows
   :selected-row
   :ignore-selecting-action
   :set-default-index
   :selected-row-fields
   :selected-row-delete
   :search-row
   :update-all-rows
   :append-new-rows
   :map-rows
   :rows-map-raw
   :rows-length
   :rows-empty-p
   :rows-remove-if
   :rows-safe-subseq
   :rows-elt
   :rows-last-elt
   :rows-first-elt
   :rows-position-if
   :rows->text-rows
   :rows->text
   :row-move
   :simple-line-navigation-window
   :selected-line-bg
   :selected-line-fg
   :resync-rows-db
   :make-blocking-list-dialog-window))

(defpackage :message-rendering-utils
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc-utils
   :db-utils
   :db)
  (:nicknames :msg-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :+temp-mention-prefix+
   :add-mention-prefix
   :strip-mention-prefix
   :local-mention->acct
   :crypto-message-destination-user
   :maybe-crypt-message
   :attachment-type->description
   :attachment-type->metadata
   :status-attachments->text
   :message-original->text-body
   :message-original->text-header
   :poll->text
   :signature))

(defpackage :thread-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :modeline-window
   :line-oriented-window
   :tui-utils
   :message-rendering-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:import-from :keybindings-window :update-keybindings-tree)
  (:export
   :message-line
   :thread-window
   :timeline-type
   :timeline-folder
   :mentions-count
   :grow-tree-to-fit-window
   :fit-timeline-to-window
   :go-message-down
   :go-message-up
   :search-next-message-body
   :search-previous-message-body
   :search-next-message-meta
   :search-previous-message-meta
   :search-next-unread
   :add-mention
   :remove-mention
   :goto-message
   :goto-first-message
   :goto-last-message
   :open-message
   :mark-selected-message-to-delete
   :mark-selected-message-prevent-delete
   :init))

(defpackage :message-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :modeline-window
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :message-window
   :metadata
   :gemini-window-p*
   :gemini-window-p
   :display-gemini-text-p
   :display-chat-p
   :row-get-original-object
   :viewport-width
   :visible-rows
   :row-vertical-space-p
   :row-preformatted-p
   :row-invisible-p
   :row-visible-p
   :row-set-visible
   :row-set-invisible
   :row-hide-preformatted
   :row-show-pre-start
   :row-show-preformatted
   :row-hide-pre-start
   :set-default-preformatted-visibility
   :get-default-preformatted-visibility
   :pre-visible-p
   :toggle-default-preformatted-visibility
   :toggle-preformatted-block
   :text->rendered-lines-rows
   :prepare-for-display-status-mode
   :prepare-for-rendering
   :scroll-down
   :scroll-up
   :scroll-end
   :scroll-begin
   :scroll-next-page
   :scroll-previous-page
   :search-regex
   :jump-to-group-id
   :generate-gemini-toc
   :gemini-toc-entry
   :gemini-toc-group-id
   :init))

(defpackage :open-attach-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :open-attach-window
   :status-id
   :refresh-view-links-window-config
   :resync-rows-db
   :open-attachment
   :init))

(defpackage :open-message-link-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :open-message-link
   :init
   :init-gemini-links
   :forget-gemini-link-window
   :init-chat-links
   :forget-chat-link-window))

(defpackage :gemini-certificates-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :open-gemini-certificates-window))

(defpackage :gemini-subscription-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :open-gemini-subscription-window))

(defpackage :gemini-page-toc
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :open-toc-window))

(defpackage :command-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :point-tracker
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:import-from :keybindings-window :update-keybindings-tree)
  (:export
   :print-error
   :command-window
   :command-line
   :echo-character
   :event-to-answer
   :prompt
   :add-error-message
   :add-info-message
   :remove-messages
   :set-history-most-recent
   :manage-event
   :set-keybinding-mode
   :set-string-mode
   :init))

(defpackage :sending-message
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :keybindings
   :specials
   :windows
   :modeline-window
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :message-ready-to-send
   :subject
   :attachments
   :reply-to
   :visibility
   :mentions
   :body
   :confirm-sending-window
   :message-data
   :init))

(defpackage :follow-requests
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :follow-requests-window
   :init
   :process-requests))

(defpackage :tags-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :tags-window
   :resync-rows-db
   :init))

(defpackage :conversations-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :conversations-window
   :resync-rows-db
   :init))

(defpackage :chats-list-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :chats-list-window
   :chat->text
   :open-chats-list-window))

(defpackage :gemini-viewer
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :specials
   :windows
   :line-oriented-window
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :push-db-stream
   :remove-db-stream
   :remove-all-db-stream
   :find-db-stream-if
   :find-db-stream-url
   :ensure-just-one-stream-rendering
   :abort-download-stream
   :db-entry-to-foreground
   :gemini-metadata-p
   :maybe-initialize-metadata
   :make-gemini-metadata
   :gemini-metadata-links
   :gemini-metadata-source-file
   :gemini-metadata-history
   :gemini-metadata-p
   :copy-gemini-metadata
   :append-metadata-link
   :append-metadata-source
   :push-url-to-history
   :pop-url-from-history
   :current-gemini-url
   :history-back
   :view-source
   :gemini-stream
   :download-iri
   :start-time
   :download-stream
   :download-socket
   :support-file
   :octect-count
   :port
   :status-code
   :status-code-description
   :meta
   :path
   :host
   :thread
   :abort-downloading
   :downloading-allowed-p
   :request
   :open-gemini-stream-window
   :load-gemini-url))

(defpackage :main-window
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :tui-utils)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :focused-window
   :focused-keybindings
   :init
   :parse-subwin-w
   :parse-subwin-h))

(defpackage :ui-goodies
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :access
   :croatoan
   :config
   :constants
   :text-utils
   :misc
   :mtree
   :specials
   :windows
   :tui-utils
   :program-events)
  (:nicknames :ui)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :delete-message-status-marked-to-delete
   :quit-program
   :clean-close-program
   :notify
   :notify-procedure
   :with-blocking-notify-procedure
   :info-dialog
   :info-dialog-immediate
   :error-dialog
   :error-dialog-immediate
   :input-dialog-immediate
   :error-message
   :info-message
   :confirm-file-overwrite-dialog-immediate
   :confirm-dialog-immediate
   :request-error-window
   :ask-string-input
   :thread-go-up
   :thread-go-down
   :thread-goto-message
   :thread-goto-first-message
   :thread-goto-last-message
   :thread-search-next-message-body
   :thread-search-previous-message-body
   :thread-search-next-message-meta
   :thread-search-previous-message-meta
   :repeat-search
   :thread-search-next-unread-message
   :thread-open-selected-message
   :thread-mark-delete-selected-message
   :thread-mark-prevent-delete-selected-message
   :subscribe-to-hash
   :unsubscribe-to-hash
   :message-scroll-up
   :message-scroll-down
   :message-scroll-begin
   :message-scroll-end
   :message-scroll-next-page
   :message-scroll-previous-page
   :message-search-regex
   :message-toggle-preformatted-block
   :focus-to-message-window
   :focus-to-thread-window
   :focus-to-send-message-window
   :focus-to-follow-requests-window
   :focus-to-tags-window
   :focus-to-conversations-window
   :print-quick-help
   :apropos-help
   :move-message-tree
   :change-folder
   :change-timeline
   :update-current-timeline
   :update-current-timeline-backwards
   :refresh-thread
   :refresh-tags
   :favourite-selected-status
   :unfavourite-selected-status
   :boost-selected-status
   :unboost-selected-status
   :ignore-user
   :unignore-user
   :message-exceeds-server-limit-p
   :exceeding-characters-notify
   :send-message
   :compose-message
   :reply-message
   :open-message-attach
   :open-message-attach-go-up
   :open-message-attach-go-down
   :open-message-attach-perform-opening
   :close-open-attach-window
   :search-link-window
   :open-message-link
   :open-message-link-go-up
   :open-message-link-go-down
   :open-message-link-perform-opening
   :open-message-link-open-enqueue
   :close-open-message-link-window
   :attach-go-up
   :attach-go-down
   :attach-delete
   :attach-add
   :follow-request-go-up
   :follow-request-go-down
   :follow-request-delete
   :start-follow-request-processing
   :cancel-follow-requests
   :process-follow-requests
   :change-subject
   :change-visibility
   :change-mentions
   :edit-message-body
   :cancel-send-message
   :close-send-message-window
   :follow-user
   :unfollow-user
   :tag-go-up
   :tag-go-down
   :open-tag-folder
   :update-conversations
   :open-conversation
   :conversation-go-up
   :conversation-go-down
   :goto-conversation
   :ignore-conversation
   :delete-conversation
   :rename-converation
   :change-conversation-name
   :report-status
   :crypto-import-key
   :crypto-export-key
   :crypto-generate-key
   :show-about-window
   :reset-timeline-pagination
   :poll-vote
   :refresh-chats
   :refresh-chat-messages
   :close-chats-list-window
   :update-all-chats-data
   :update-all-chats-messages
   :open-chats-list-window
   :show-chat-to-screen
   :chat-loop
   :open-chat-link-window
   :change-chat-label
   :chat-create-new
   :chat-list-go-up
   :chat-list-go-down
   :gemini-open-url-prompt
   :open-gemini-address
   :gemini-history-back
   :gemini-view-source
   :gemini-abort-download
   :gemini-open-streams-window
   :gemini-open-certificates-window
   :gemini-certificate-window-move
   :gemini-certificate-window-go-down
   :gemini-certificate-window-go-up
   :gemini-close-certificate-window
   :gemini-delete-certificate
   :gemini-streams-window-up
   :gemini-streams-window-down
   :gemini-streams-window-close
   :gemini-streams-window-open-stream
   :gemini-refresh-page
   :gemini-subscribe-gemlog
   :gemini-open-gemlog-window
   :gemlogs-subscription-go-up
   :gemlogs-subscription-go-down
   :close-gemlog-window
   :show-gemlog-to-screen
   :gemlog-refresh-all
   :gemlog-cancel-subscription
   :send-to-pipe
   :send-message-to-pipe
   :tour-mode-link
   :next-tour-link
   :show-tour-links
   :open-gemini-toc
   :gemini-toc-scroll-up
   :gemini-toc-scroll-down
   :gemini-toc-jump-to-entry
   :gemini-toc-close
   :pass-focus-on-left
   :pass-focus-on-right
   :pass-focus-on-bottom
   :pass-focus-on-top))

(defpackage :scheduled-events
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :misc-utils
   :text-utils
   :specials)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export
   :refresh-refresh-all-chats-data
   :refresh-refresh-all-chats-messages
   :run-scheduled-events))

(defpackage :modules
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :config
   :constants
   :text-utils
   :resources-utils
   :specials
   :db-utils
   :windows
   :sending-message
   :keybindings
   :program-events
   :ui-goodies)
  (:shadowing-import-from :resources-utils :init)
  (:export
   :load-sys-module
   :load-module))

(defpackage :scripts
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :config
   :constants
   :text-utils
   :misc-utils
   :api-client)
  (:shadowing-import-from :misc :random-elt :shuffle)
  (:export))

(defpackage :main
  (:use
   :cl
   :alexandria
   :cl-ppcre
   :croatoan
   :config
   :constants
   :text-utils
   :command-line)
  (:export))
